import http from '@/api/http'

// 点赞/踩
const handlePl=(data) => {
    return http({
        url: "chapter/iszan",
        method: "post",
        data: data
    })
} 

// 撤回评论 (删除)
const delComment=(data) => {
    return http({
        url: "chapter/delComment",
        method: "get",
        params: data
    })
} 

// 获得全部评论
const getallcomments=(data) => {
    return http({
        url: "chapter/comments",
        method: "get",
        params: data
    })
} 

// 发送一条评论
const sendComent=(data) => {
    return http({
        url: "chapter/addComment",
        method: "post",
        data: data
    })
} 

// 用户访问记录
const addAccess=(data) => {
    return http({
        url: "user/addAccess",
        method: "post",
        data: data
    })
}

// 退出登陆
const signOut=(data) => {
    return http({
        url: "user/signOut",
        method: "post",
        data: data
    })
}

// 获取上一章，下一章的内容
const getNextChapter=(data) => {
    return http({
        url: "chapter/chooseChpater",
        method: "get",
        params: data
    })
}

// 提交阅读记录
const putCollection=(data) => {
    return http({
        url: "user/updataCollection",
        method: "post",
        data: data
    })
}

// 删除藏书
const delCollection=(data) => {
    return http({
        url: "user/delCollection",
        method: "get",
        params: data
    })
}

// 获取全部藏书
const getAllCollections=(data) => {
    return http({
        url: "user/collections",
        method: "get",
        params: data
    })
}

// 加入书架
const addBook = (data) => {
    return http({
        url: "user/collection",
        method: "post",
        data: data
    })
}

// 登陆
const getLogin = (data) => {
    return http({
        url: "user/login",
        method: "get",
        params: data
    })
}

// 注册
const getRegister = (data) => {
    return http({
        url: "user/register",
        method: "post",
        data: data
    })
}

// 获取单个book的基本信息
const getBook = (data) => {
    return http({
        url: `chapter/book/${data.id}`,
        method: "get",
    })
}

// 获取一个分类下books的封面信息
const getBooks = (data,id) => {
    return http({
        url: `chapter/books/${id}`,
        method: "get",
        params: data
    })
}

// 获取book的所有章节信息
const getChapters = (data) => {
    return http({
        url: `chapter/chapters`,
        method: "get",
        params: data
    })
}

// 获取book的所有章节信息
const getChapter = (data) => {
    return http({
        url: `chapter/chapter`,
        method: "get",
        params: data
    })
}


export {
    getLogin,
    getRegister,
    getBooks,
    getChapters,
    getChapter,
    addBook,
    getAllCollections,
    delCollection,
    putCollection,
    getNextChapter,
    getBook,
    signOut,
    addAccess,
    sendComent,
    getallcomments,
    delComment,
    handlePl
}






